-
Notifications
You must be signed in to change notification settings - Fork 15.4k
DAG: Avoid using getLibcallName for function support test #170583
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
We had a set of utilities which was only used for some set of floating point libcalls. Add more, most of which are for integer operations. Ideally we would generate these functions from tablegen.
Contributor
Author
This was referenced Dec 4, 2025
Member
|
@llvm/pr-subscribers-llvm-selectiondag Author: Matt Arsenault (arsenm) ChangesFull diff: https://github.com/llvm/llvm-project/pull/170583.diff 3 Files Affected:
diff --git a/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp b/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
index 8336e1d1f4134..2d2d39dab864a 100644
--- a/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
@@ -3878,7 +3878,7 @@ bool SelectionDAGLegalize::ExpandNode(SDNode *Node) {
RTLIB::Libcall LC = RTLIB::getLDEXP(VT);
// Use the LibCall instead, it is very likely faster
// FIXME: Use separate LibCall action.
- if (TLI.getLibcallName(LC))
+ if (TLI.getLibcallImpl(LC) != RTLIB::Unsupported)
break;
if (SDValue Expanded = expandLdexp(Node)) {
@@ -3893,7 +3893,7 @@ bool SelectionDAGLegalize::ExpandNode(SDNode *Node) {
RTLIB::Libcall LC = RTLIB::getFREXP(Node->getValueType(0));
// Use the LibCall instead, it is very likely faster
// FIXME: Use separate LibCall action.
- if (TLI.getLibcallName(LC))
+ if (TLI.getLibcallImpl(LC) != RTLIB::Unsupported)
break;
if (SDValue Expanded = expandFrexp(Node)) {
@@ -4695,7 +4695,7 @@ void SelectionDAGLegalize::ConvertNodeToLibcall(SDNode *Node) {
RTLIB::Libcall LC = RTLIB::getOUTLINE_ATOMIC(Opc, Order, VT);
EVT RetVT = Node->getValueType(0);
SmallVector<SDValue, 4> Ops;
- if (TLI.getLibcallName(LC)) {
+ if (TLI.getLibcallImpl(LC) != RTLIB::Unsupported) {
// If outline atomic available, prepare its arguments and expand.
Ops.append(Node->op_begin() + 2, Node->op_end());
Ops.push_back(Node->getOperand(1));
@@ -4961,7 +4961,7 @@ void SelectionDAGLegalize::ConvertNodeToLibcall(SDNode *Node) {
case ISD::STRICT_FPOWI: {
RTLIB::Libcall LC = RTLIB::getPOWI(Node->getSimpleValueType(0));
assert(LC != RTLIB::UNKNOWN_LIBCALL && "Unexpected fpowi.");
- if (!TLI.getLibcallName(LC)) {
+ if (TLI.getLibcallImpl(LC) == RTLIB::Unsupported) {
// Some targets don't have a powi libcall; use pow instead.
if (Node->isStrictFPOpcode()) {
SDValue Exponent =
diff --git a/llvm/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp b/llvm/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp
index 383a025a4d916..dbdd913fccdb2 100644
--- a/llvm/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp
@@ -717,7 +717,7 @@ SDValue DAGTypeLegalizer::SoftenFloatRes_ExpOp(SDNode *N) {
RTLIB::Libcall LC = IsPowI ? RTLIB::getPOWI(N->getValueType(0))
: RTLIB::getLDEXP(N->getValueType(0));
assert(LC != RTLIB::UNKNOWN_LIBCALL && "Unexpected fpowi.");
- if (!TLI.getLibcallName(LC)) {
+ if (TLI.getLibcallImpl(LC) == RTLIB::Unsupported) {
// Some targets don't have a powi libcall; use pow instead.
// FIXME: Implement this if some target needs it.
DAG.getContext()->emitError("do not know how to soften fpowi to fpow");
@@ -802,7 +802,7 @@ bool DAGTypeLegalizer::SoftenFloatRes_UnaryWithTwoFPResults(
assert(VT == N->getValueType(1) &&
"expected both return values to have the same type");
- if (!TLI.getLibcallName(LC))
+ if (TLI.getLibcallImpl(LC) == RTLIB::Unsupported)
return false;
EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
@@ -862,7 +862,8 @@ SDValue DAGTypeLegalizer::SoftenFloatRes_FSINCOS(SDNode *N) {
RTLIB::Libcall CosLC = RTLIB::getCOS(VT);
SDValue SoftSin, SoftCos;
- if (!TLI.getLibcallName(SinLC) || !TLI.getLibcallName(CosLC)) {
+ if (TLI.getLibcallImpl(SinLC) == RTLIB::Unsupported ||
+ TLI.getLibcallImpl(CosLC) == RTLIB::Unsupported) {
DAG.getContext()->emitError("do not know how to soften fsincos");
EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
diff --git a/llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp b/llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp
index 0160723553a8e..8c9f5eeebd26c 100644
--- a/llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp
@@ -2692,7 +2692,7 @@ SDValue DAGTypeLegalizer::PromoteIntOp_ExpOp(SDNode *N) {
RTLIB::Libcall LC = IsPowI ? RTLIB::getPOWI(N->getValueType(0))
: RTLIB::getLDEXP(N->getValueType(0));
- if (LC == RTLIB::UNKNOWN_LIBCALL || !TLI.getLibcallName(LC)) {
+ if (TLI.getLibcallImpl(LC) == RTLIB::Unsupported) {
// Scalarize vector FPOWI instead of promoting the type. This allows the
// scalar FPOWIs to be visited and converted to libcalls before promoting
// the type.
|
RKSimon
approved these changes
Dec 4, 2025
Collaborator
RKSimon
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Base automatically changed from
users/arsenm/dag/use-more-rtlib-get-helpers
to
main
December 4, 2025 16:49
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.

No description provided.